package io

type BombReducer struct {
	CardReducer
}

func (c BombReducer) Pattern() int {
	return c.CardReducer.Pattern
}

func (c BombReducer) Reduce(cards []Card) (outCards []Card) {
	outCards = []Card{}

	for i, v := range cards {
		curCard := v
		outCards = append(outCards, curCard)
		for j := i + 1; j < len(cards); j++  {
			nextCard := cards[j]

			if nextCard.Value == curCard.Value {
				outCards = append(outCards, nextCard)
				break
			} else {
				curCard = nextCard
				continue
			}
		}

		if len(outCards) >= 4 {
			break
		} else {
			outCards = []Card{}
			continue
		}
	}

	return
}